package main

import (
	"encoding/json"
	"fmt"
	"sync/atomic"
)

type A struct {
	RunningTasks *atomic.Int32 `json:"running_tasks"` // 指的是同时运行的任务数量
}

func f() {

	count := 10
	for i := 0; i < count; i++ {

		fmt.Println("当前索引:", i, "剩余:", count-(i+1))
	}
}

func f1() {
	a := []int{1, 2, 3, 4, 5}
	b := make([]int, len(a), len(a))
	copy(b, a)

	a = a[:0]
	fmt.Println(a, len(a), cap(a))
	fmt.Println(b, len(b), cap(b))

	a = append(a, 6)
	fmt.Println(a, len(a), cap(a))
}

func main() {
	f1()
	return
	a := A{
		RunningTasks: &atomic.Int32{},
	}
	a.RunningTasks.Add(3)

	fmt.Println(a.RunningTasks.Load())
	b, _ := json.Marshal(a)
	fmt.Println(string(b))
}
